<!DOCTYPE html>
<html>
<head>
    <title>{{ apiTitle }}</title>
    <link href="{{ webjarsAt 'swagger-ui/images/favicon-32x32.png' }}" sizes="32x32" rel="icon" type="image/png">
    <link href="{{ webjarsAt 'swagger-ui/images/favicon-16x16.png' }}" sizes="16x16" rel="icon" type="image/png">
    <link href="{{ webjarsAt 'swagger-ui/css/typography.css' }}" media='screen' rel="stylesheet" type='text/css'>
    <link href="{{ webjarsAt 'swagger-ui/css/reset.css' }}" media='screen' rel='stylesheet'>
    <link href="{{ webjarsAt 'swagger-ui/css/screen.css' }}" media='screen' rel='stylesheet'>
    <link href="{{ webjarsAt 'swagger-ui/css/reset.css' }}" media='print' rel='stylesheet'>
    <link href="{{ webjarsAt 'swagger-ui/css/print.css' }}" media='print' rel='stylesheet'>

    <script src="{{ webjarsAt 'swagger-ui/lib/object-assign-pollyfill.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/jquery-1.8.0.min.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/jquery.slideto.min.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/jquery.wiggle.min.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/jquery.ba-bbq.min.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/handlebars-4.0.5.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/lodash.min.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/backbone-min.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/swagger-ui.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/highlight.9.1.0.pack.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/highlight.9.1.0.pack_extended.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/jsoneditor.min.js' }}"></script>
    <script src="{{ webjarsAt 'swagger-ui/lib/marked.js' }}"></script>

    <!-- enabling this will enable oauth2 implicit scope support -->
    <script src="{{ webjarsAt 'swagger-ui/lib/swagger-oauth.js' }}"></script>

    <script type="text/javascript">
        $(function () {
            var url = "{{appPath}}/{{swaggerPath}}/swagger.json";
            window.swaggerUi = new SwaggerUi({
                url: url,
                dom_id: "swagger-ui-container",
                supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
                onComplete: function(swaggerApi, swaggerUi){
                    if(typeof initOAuth == "function") {
                        initOAuth({
                            clientId: "your-client-id",
                            realm: "your-realms",
                            appName: "your-app-name"
                        });
                    }
                    $('pre code').each(function(i, e) {
                        hljs.highlightBlock(e)
                    });
                    addApiKeyAuthorization();
                },
                onFailure: function(data) {
                    log("Unable to Load SwaggerUI");
                },
                docExpansion: "none",
                jsonEditor: false,
                apisSorter: "alpha",
                showRequestHeaders: false
            });
            function addApiKeyAuthorization(){
                var key = encodeURIComponent($('#input_apiKey')[0].value);
                if(key && key.trim() != "") {
                    var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("{{apiKeyName}}", key, "{{apiKeyType}}");
                    window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth);
                    log("added key " + key);
                }
            }
            $('#input_apiKey').change(addApiKeyAuthorization);
            $('#input_apiKey').val("{{apiKey}}");

            window.swaggerUi.load();
            function log() {
                if ('console' in window) {
                    console.log.apply(console, arguments);
                }
            }
        });
    </script>
</head>

<body class="swagger-section">
<div id='header'>
    <div class="swagger-ui-wrap">
        <a id="logo" href="{{appPath}}">{{bannerText}}</a>
        <form id='api_selector'>
            <div class='input'><input hidden="true" placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
            <div class='input'>
                {{#hideApiKey}}
                    <input hidden placeholder="{{apiKeyName}}" id="input_apiKey" name="apiKey" type="text" value="{{apiKey}}" />
                {{/hideApiKey}}
                {{^hideApiKey}}
                    <input placeholder="{{apiKeyName}}" id="input_apiKey" name="apiKey" type="text" value="{{apiKey}}"/>
                {{/hideApiKey}}
            </div>
        </form>
    </div>
</div>

<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>
